
function startwater(obj){
    setTimeout(function(){
        for(var i=0;i<$('.bimg .pin img').length;i++){
            if($('.bimg .pin img').eq(i).height()>800){
                $('.bimg .pin img').eq(i).parent().css({
                    height:800,
                    overflow:'hidden',
                    display:'inline-block',
                    position:'relative'
                })
                var span = $("<span class='bottom_img'></span>");
                $('.bimg .pin img').eq(i).parent().append(span)
            }
        }
        water($('.box'),obj.num,obj.num);   
    },300)
    var stop = true;
    var num=1;
    $(window).scroll(function(){
        var lastBox = $('.box').eq($('.box').length-1);
        if(getLast($('.box'))&&stop&&$('.box:animated').length==0){
            var array = [];
            var inum = $('.box').length;
            var dt;
            if(obj.data){
                dt = 'num='+num+"&"+obj.data;
            }else{
                dt = 'num='+num;
            }
            $.ajax({
                'url':app+'/'+obj.url,
                data:dt,
                type:'post',
                dataType:'json',
                beforeSend:function(){
                    $('.floor').show()
                    stop=false; 
                },
                success:function(data){
                    if(data.num==0){
                        stop=false;
                        $('.floor').hide()
                        return false;
                    }
                    //  data = eval(data);     
                    for(var i in data){
                        var bo = $("<div class='box bimg'></div>");
                        // var box = "<div class='box bimg'>";
                        var  box = "<a class='turn li'><span class='img'></span>转采</a>";
                        if(uid==data[i].uid){
                            box += "<a class='li li1' href='"+app+"/?m=Complete&a=editimg&id="+data[i].id+"'>";
                            box += "编辑";
                            box += " </a>";
                        }else{
                            box += " <a class='li1 li good' name='"+data[i].id+"'>";
                            box += "   <span class='img'></span><span class='good_num'>"+data[i].num+"</span>赞";
                            box += " </a> ";
                        }
                        bo.html(box)
                        var border = $("<div class='border'></div>");
                        var box = " <div class='good_mesa'>";
                        box += "<span class='good_s'></span> ";
                        box += "<div>";
                        box += "<textarea class='comcont good_cont' placeholder='添加评论或把采集@给好友' autocomplete='off' style='background-color: rgb(255, 255, 255);'></textarea>";
                        box += " <a href='javascript:;' class='combtn com_btn' name='"+data[i].id+"'></a>";
                        box += " </div>";  
                        box += "</div>";
                        border.html(box);
                        var pin= $("<div class='pin'></div>");
                        var a= $("<a href='#'></a>");
                        
                        a.attr('href', app+"/Complete/showimg/id/"+data[i].id);
                        var img=$("<img>"); 
                        getImg(data[i].adres,192,1,callback,img);
                        img.attr('src',data[i].adres);
                        if(call){
                            if(img.height()>800){
                                a.css({
                                    height:800,
                                    overflow:'hidden',
                                    display:'inline-block',
                                    position:'relative'
                                })
                                var span = $("<span class='bottom_img'></span>");
                                a.append(img)  
                                a.append(span)
                            }else{
                                a.append(img)   
                            }
                            var p =$("<p></p>");
                            
                            p.html(data[i].mesa);
                            pin.html(box);
                            border.append(pin) 
                            pin.append(a);           
                            pin.append(p)
                            if(!obj.bottom){
                                var bottom = $("<div class='bottom'></div>");
                                var box= "<a href='"+app+"/?m=Complete&a=showuser&uid="+data[i].uid+"'><img src='"+data[i].thump+"' /></a><p><a href='"+app+"/?m=Complete&a=showuser&uid="+data[i].uid+"'>"+data[i].uname+"</a> 采集到 <a href='#'>"+data[i].name+"</a></p>";
                                box += "<a href='javascript:;' class=comment name='"+data[i].id+"' a='1'></a>"
                                bottom.html(box);
                                border.append(bottom);
                            }
                            if(data[i].sort){
                                var sort = data[i].sort
                                for(var k in sort){
                                    var bottom= $("<div class='bottom'></div>");
                                    var box = "<a href='"+app+"/?m=Complete&a=showuser&uid="+sort[k].uid+"'><img src='"+sort[k].thump+"'></a>";
                                    box += "<p><a href='"+app+"/?m=Complete&a=showuser&uid="+sort[k].uid+"'>"+sort[k].uname+"</a> : "+sort[k].content.substring(0,10)+"</p>";
                                    box += "<a class='comment' href='javascript:;' a='1' name='"+sort[k].mid+"'></a>";
                                    bottom.html(box);
                                    border.append(bottom)
                                }
                            }
                            bo.append(border);
                            setObj(bo);
                            $('#water').append(bo);
                            if(array.length){
                                array.splice(i,1);
                            }
                        }else{ 
                            var st = true;
                            if(array.length){
                                for(var j in array){
                                    if(array[j] == data[i]){
                                        st = false;
                                    }
                                }  
                            }
                            if(st){
                                array.push(data[i]);
                            }
                        }
                               
                    }
                    if(array.length){
                        var _this = this;
                        setTimeout(function(){
                            _this.success(array);
                        },100)
                    }else{
                        water($('.box'),obj.num,inum);
                        stop = true;
                        num++ 
                    }
                },
                complete:function(){

                    $('.floor').hide()
                }
            })
        }
    })
}


